package com.zbf.date1;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author: LCG
 * @date: 2023-05-23 18:54:50
 * @description:
 **/
public class DateUtils123 {
    public static void main(String[] args) {

        String[] replaceDates={"2023-05-26","2023-05-25","2023-05-27"};
        List<String> collect = Arrays.stream(replaceDates).sorted(new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                DateTime parse1 = DateUtil.parse(o1, "yyyy-MM-dd");
                DateTime parse2 = DateUtil.parse(o2, "yyyy-MM-dd");
                if (parse1.getTime() >= parse2.getTime()) {
                    return 1;
                } else {
                    return -1;
                }
            }
        }).collect(Collectors.toList());

        System.out.println(JSON.toJSONString(collect));

    }
}
